package itheima.com.Utiley;

import org.junit.Test;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class OutputStream_ {

    public static void main(String[] args) {

    }

    @Test
    public void writeFile(){
        String filePath = "D:\\一条小团团\\小团团.txt";
        FileOutputStream  fileOutputStream = null;

        try {
            fileOutputStream = new FileOutputStream(filePath,true);
//
            String str = "hello,world!";

//            写入一个字节
            fileOutputStream.write(str.getBytes(),0,str.length());

        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            try {
                fileOutputStream.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

    }


}
